package com.yuxiu.edu.web.controller.base;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

public abstract class BaseController<T> {
    public  static String MANAGE_PAGE;  //管理页面
    public  static String INFO_PAGE;    //列表页面
    public  static String ADD_PAGE;    //新增页面
    public  static String UPDATE_PAGE;    //编辑页面
    public  static String OTHERS_PAGE;    //其它页面

    public  static final String MANAGE="manage";  //管理
    public  static final String INFO="info";    //列表
    public  static final String ADD="add";    //新增
    public  static final String UPDATE="update";    //编辑
    public  static final String OTHERS="others";    //其它

    public BaseController(){
        //1.获取泛型的真实类型
        ParameterizedType type = (ParameterizedType)this.getClass().getGenericSuperclass();
        System.out.println(type);
        Class<?> model_class = (Class<?>)type.getActualTypeArguments()[0];
        System.out.println(model_class);

        String modelName = model_class.getSimpleName().toLowerCase();

        MANAGE_PAGE=modelName+"/"+MANAGE;
        INFO_PAGE=modelName+"/"+INFO;
        ADD_PAGE=modelName+"/"+ADD;
        UPDATE_PAGE=modelName+"/"+UPDATE;
        OTHERS_PAGE=modelName+"/"+OTHERS;

    }



}
